package com.luff.thread.handler;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Create By The-Long time 2021/10/6 20:08
 **/

public class MyRejectedHandler implements RejectedExecutionHandler {

    //抛出拒绝策略
    public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
        doLog(r, e);
    }

    private void doLog(Runnable r, ThreadPoolExecutor e) {
        // 可做日志记录等
        /*打印错误日志*/
        System.err.println( r.toString() + " 此任务被拒绝");
          System.out.println("completedTaskCount: " + e.getCompletedTaskCount());
    }
}
